package com.hans.scala.traits

/**
 * 特质
 * 如果要在多个不相关的类中重用，就做成特质
 * 如果你希望从Java代码中继承它，就使用抽象类
 * 如果效率非常重要，倾向于类
 */
object Cat extends App {
  class Animal {
    val memo = "a1"

    def des() {
      println("it is animal.")
    }
  }

  trait Furry extends Animal {
    //  override val memo = "f1"
    override def des() {
      println("it is furry.")
    }
  }

  trait FurryLegged extends Animal {
    override def des() {
      println("it is furry legged.")
    }
  }

  class Cat extends Animal with FurryLegged with Furry {
  }

  val c = new Cat
  c.des()
  println(c.memo)
}
